<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>检查一个字符串是否以指定的字符串结尾</title>
</head>
<body>
    
</body>
<script>
    let str = 'abc1';

    function fun(str, val) {
        return str[str.length - 1] == val ? true : false;
    }

    console.log(fun(str, 1));
</script>
</html>